package com.lzb.randomturntable.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.basic.ProviderMultiAdapter;
import com.lzb.randomturntable.R;
import com.lzb.randomturntable.bean.CoinBean;
import com.lzb.randomturntable.bean.CoinBean;

public class CoinAdapter extends ProviderMultiAdapter<CoinBean> {

    public CoinAdapter() {
        addItemProvider(new CoinProvider());
    }

    private class CoinProvider extends BaseItemProvider<CoinBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_coin;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, CoinBean bean) {
            baseViewHolder.setImageResource(R.id.ivCoinItemFront, bean.getFrontImg());
            baseViewHolder.setImageResource(R.id.ivCoinItemReverse, bean.getReverseImg());
            if (bean.isSelected()){
                baseViewHolder.setBackgroundResource(R.id.rlCoinItem,R.drawable.blue_15_dp);
                baseViewHolder.getView(R.id.ivCoinItemSel).setVisibility(View.VISIBLE);
            }else {
                baseViewHolder.setBackgroundResource(R.id.rlCoinItem,R.drawable.white_10_15_dp);
                baseViewHolder.getView(R.id.ivCoinItemSel).setVisibility(View.GONE);
            }
        }
    }
}